perm filename EYE.WRU[SYS,HE] blob sn#004172 filedate 1972-06-01 generic text, type T, neo UTF8
00100			EDGE FOLLOWER AND CURVE FITTER DOCUMENTATION
00200	
00300				by K. PINGLE
00400	
00500	
00600	I. INTRODUCTION
00700	
00800		The edge follower consists of four files:
00900	CONTRL is the control program which handles TTY input and message
01000		procedures, dispatching to the appropriate routines.
01100	EDGE contains the edge tracing programs.
01200	MISEDG contains other message procedures and routines used by the
01300		edge follower
01400	SCANER contains the accomodation routines.
01500	
01600		The curve fitter is a seperate job and consists of two files:
01700	CURVE is the main curve fitting program.
01800	MISCUR contains routines used by the curve fitter.
01900	
02000		The curve fitter can be activated  by  itself  or  through  a
02100	message procedure from the edge follower.
02200	
02300		The  edge follower control program accepts input from the TTY
02400	as well as message procedures.  The TTY input is normally used to run
02500	the  edge  follower  by  itself,  or  when only the monitor and curve
02600	fitter are running with it, but can be used with  message  procedures
02700	from  a  strategy  program  for  error  recovery  or debugging.  Most
02800	commands can be given either through message procedures or  the  TTY.
02900	The form of the commands are given in the descriptions as:
03000	
03100	TTY: format when typed in
03200	MP: message procedure declaration
03300	FILE: file which contains the code executed by this command or, if
03400		there are several levels of calls, the file containing the
03500		procedure which actually does most of the work.  The 
03600		procedure name is given in parenthesis.
03700	
03800		Most commands return status information, especially  when  an
03900	error  occurs.   If  the  command  was called from the TTY, the error
04000	output goes to the TTY only.  If the command was called by a  message
04100	procedure the error is indicated in the message procedure returned to
04200	the calling program or by a  status  word  provided  by  the  caller.
04300	Certain fatal errors are always sent to the TTY and the program dies.
04400	Most of these are caused by bugs in the edge follower or  garbage  in
04500	the second segment.
04600	
04700		If an error is made in typing a command, the string  COM  ERR
04800	followed  by  the  incorrect  command will be typed.  An error in the
04900	arguments will either be detected by the command or  the  string  ARG
05000	ERR possibly followed by the argument will be typed.
     

00100	II. MISC. COMMANDS
00200	
00300		The first group of commands are miscellaneous  operations  to
00400	initialize  the edge follower, change its status, or inspect results.
00500	Several of the message procedures have, as one  of  their  arguments,
00600	'REFERENCE  BOOLEAN FLAG', which returns a value.  This value will be
00700	accessable to the calling program only if FLAG is a global variable.
00800	
00900	1. INITIALIZE THE EDGE FOLLOWER
01000	
01100	TTY: INIT
01200	MP: RESTART_KKP;
01300	FILE: CONTRL (RESTART_KKP)
01400	
01500		The  command  reinitializes  the display programs for a fresh
01600	display, clears free storage and all pointers to it, and  initializes
01700	the  variables mentioned under SETVAL to their default values.  It is
01800	equivalent to restarting the program.  Visual input is initialized to
01900	come  from  the TV camera.  This procedure is called when the program
02000	is first started.
02100	
02200	2. SET INPUT TO TV
02300	
02400	TTY: TV
02500	MP: TV;
02600	FILE: MISEDG  (INITTV)
02700	
02800		This  command releases any existing TV buffers and gets a new
02900	one which size is computed using TVWID (see SETVAL), but  never  less
03000	than  500 words.  The default values of the limits of the scan (TMAX,
03100	BMAX, LSMAX, RSMAX) are set to 10, 250, 10, 325.  XSTRT and YSTRT are
03200	cleared  to  force  a  complete scan.  The procedure is called by the
03300	first command and is the default option for visual input.
03400	
03500	3.  SET VISUAL INPUT TO COME FROM A DISK FILE
03600	
03700	TTY: DISK FILE_NAME
03800	MP: DISK(STRING FILE_NAME; REFERENCE BOOLEAN FLAG);
03900	FILE: MISEDG  (INITDK)
04000	
04100		This  command released any existing TV buffers and reads in a
04200	disk file with library routine DISKIN, which creates a TV buffer  the
04300	exact  length of the data.  FILE_NAME ia the name of the file and may
04400	contain a progrect,programmer pair (the one the program is logged  in
04500	on  is  assumed  otherwise).   The  extension  DAT is assumed and any
04600	extension given is ignored.  The file read in must be in  the  format
04700	used  by  library routines DSKDMP.  The default values of TMAX, BMAX,
04800	RSMAX, and LSMAX are set from the file's header  information.   XSTRT
04900	and  YSTRT  are cleared.  Flags are set to prevent the routines which
05000	access the TV buffer from trying to  read  new  data  when  the  scan
05100	reaches  the  edge of the buffer and TV accomodation is disabled.  If
05200	the file cannot be found either FLAG ← FALSE (TRUE if file found)  or
05300	"file_name  NOT  FOUND"  is typed.  See the library documentation for
05400	error messages from DISKIN.
05500	
05600	4. EXECUTE A SUBROUTINE
05700	
05800	TTY: XEQ NAME
05900	MP: XEQ(STRING NAME; REFERENCE BOOLEAN FLAG);
06000	FILE: CONTRL  (XEQ)
06100	
06200	The  symbol  table  is  searched for the variable NAME, which must be
06300	INTERNAL or ENTRY, and executes it as a subroutine with no arguments,
06400	using  the  normal  SAIL  calling  sequence.  If the symbol cannot be
06500	found either FLAG←FALSE (TRUE otherwise) or "NO name" is typed. While
06600	any  procedure  of  no  arguments  can  be executed, such as TVIN, or
06700	PRDUMP is it is loaded, the following  two  procedures  are  normally
06800	executed  by  it:  .GARCO is force garbage collection of free storage
06900	and EDGTYP, which sets TYP_EDGE to TRUE so you can get  typeout  when
07000	the monitor is not around.
07100	
07200	5. TURN ON OR OFF DEBUGGING
07300	
07400	TTY: DEBUG NAME {ON|OFF}
07500	MP: DEBUG(STRING NAME, VAL; REFERENCE BOOLEAN FLAG);
07600	FILE: CONTRL  (DEBUG)
07700	
07800		VAL contains either  ON  or  OFF.   These  two  commands  are
07900	equivalent  to  XEQ NAME[1 TO 4]&"ON" and XEQ NAME[1 TO 3]&"OFF". The
08000	routines executed as assumed to turn on and off debugging.  Currently
08100	only two names  are  valid:  EDGE  controls  debugging  in  the  edge
08102	follower and ACCOM controls debugging in the accomodation routines.
08104		The effect of EDGE debugging is to cause a  moving  point  on
08106	the  display  to  show  where  the  edge  follower  is  applying  its
08108	operators.  This makes the program run slowly.   Also,  GUNTRACE  and
08110	FINE  will  draw  rectangles  around the areas they are scaning.  The
08112	display from the curve  fitter  will  be  superimposed  on  the  edge
08114	points.
08116		The effect of ACCOM may be described later.
08400	
08500	6. CHANGE A VARIABLE
08600	
08700	TTY: SETVAL NAME VAL
08800	MP: SETVAL(STRING NAME; INTEGER VAL; REFERENCE BOOLEAN FLAG);
08900	FILE: CONTRL (SETVAL)
09000	
09100		This  command  sets  variable  NAME to the value VAL and sets
09200	FLAG← FALSE if not found (TRUE if found).  The table  below  contains
09300	the  variables  which  control  the  edge follower.   They are set to
09400	default values when the program is initiallized.  If you  attempt  to
09500	set  their  value  outside the limits given, the value will be set to
09600	the nearest limit.   If NAME is not in this list,  the  symbol  table
09700	will  be  searched  for  the variable, which must be INTERNAL. GLOBAL
09800	variables cannot be accessed by this command.   It  has  better  like
09900	having  an  integer  value  if  the  command  is  called by a message
10000	procedure.  If called from the TTY, VAL will be interpreted  as  real
10100	if a decimal point appears in it.
     

00100	VARIABLE MIN	MAX	DEFAULT	USE
00200	****	****	****	*****	**********************************
00300	START	0	0	0	sets XSTRT←YSTRT←0 which initializes
00400					the next scan to the bottom of the
00500					image.
00600	XINC	-100	100	8	the X increment for the coarse scan
00700					used to find an object.  Zero is not
00800					a legal value.  A positive value gives
00900					a left to right scan; a negative value
01000					the reverse.
01100	YINC	-100	100	8	the Y increment
01200	GRIDTH	1	17	4	the intensity difference needed for
01300					the coarse scan to detect an edge
01400					(assuming four bit samples, for other
01500					width  samples the value used is
01600					adjusted to maintain the ratio).
01700	TRACETH	1	77	4	the threshold for the operator which
01800					is tracing the object.  The lower the
01900					number the more sensitive it is.
02400	SPACE	-1	1	-1	The relative trace increment while
02500					tracing around an object.  -1=file,
02600					0=medium,1=coarse.
02900	OPSIZE	1	3	2	size of the Huekel operator used.
03000	TOP	1	256	10	top of image (TMAX) WARNING: this,
03100					and the next three variables, are
03200					not checked for the proper relation-
03300					ships between them.
03400	LEFT	1	333	10	left limit of image (LSMAX)
03500	BOTTOM	1	256	250	bottom of image (BMAX)
03600	RIGHT	1	333	325	right limit of image (RSMAX)
03700	TVWID	none	none	65	width of the square area of the image
03800					read in by each call of  TVIN, the
03900					library TV input routine.  A change
04000					is made only when command TV is
04100					executed.
04102	CONF	none	none	.9	confidence for Huekel operator
04104	DIFF	none	none	1.5	mininum intensity difference for Huekel
04106					operator
04108	
04200	7. LOOK AT A VARIABLE
04300	
04400	TTY: GETVAL NAME
04500	MP: none
04600	FILE:CONTRL  (GETVAL)
04700	
04800		The contents of NAME is typed, either in floating point, or
04900	octal and integer, as the program deems appropriate.  The name may
05000	be from the list for SETVAL or any INTERNAL variable.
     

00100	8.  GET EDGE FOLLOWER OUTPUT
00200	
00300	TTY: GETDATA OBJECT
00400	MP: GETDATA(ITEMVAR ARG; REFERENCE BOOLEAN FLAG);
00500	FILE: MISEDG   (XGETD)
00600	
00700		GETDATA transfers edge points to the calling job.  ARG is the
00800	item of the object whose edge points are desired.  OBJECT is the item
00900	number of the object.  FLAG is set false if the object does not exist
01000	or  if  it  has no edge points (the command COMPACT has been executed
01100	for it); FLAG is true otherwise.  Specifying ARG=EVERY or  OBJECT=-1,
01200	as  can be done for some similar commands, is illegal. An array, DAT,
01300	is created and filled with the edge points as follows.  The edge data
01400	structure  is  divided  into  segments.  At most one segment may be a
01500	closed curve containing all edge points around  the  outline  of  the
01600	object.    The other segments, if any, are the edge points for a line
01700	segment, or a series of connecting line  segments.    The  number  of
01800	segments  and  the  ordering  of  the  points  in  them  may vary for
01900	different traces of the same object, depending on how it was  traced.
02000	Each  segment  is  in a block in DAT.  DAT[I,1], where I is the first
02100	element of the block, contains the word count for the block, which is
02200	negative  if  the  segment is not a closed curve.  There is, at most,
02300	one block containing a closed curve.  DAT[I,2] is the index in DAT of
02400	the  start  of  the  next  block  or  zero  if  this is the last one.
02500	Therefore, the next count is in  DAT[DAT[I,2],1].    The  coordinates
02600	follow  the count and index with X in DAT[I+n,1] and Y in DAT[I+n,2],
02700	n=1,2,...,abs(DAT[I,1]).  DAT has bounds 1:MAXCNT,1:2.
02800		If  the  command  was given from the TTY, DAT will be written
02900	onto a disk file, in text format, with  MAXCNT  in  the  first  line,
03000	followed  by  DAT[J,1]  and  DAT[J,2]  J=1,MAXCNT  on the next MAXCNT
03100	lines. If the edge follower is running under  the  monitor  the  file
03200	name  will  be  "DATA"&cvs(RUN  mod 100).  Otherwise the command will
03300	type "SET NUMBER=" and the number typed will be used instead of  RUN.
03400	The  file  has  no  extension.  If the command was given by a message
03500	procedure, the procedure returns  to  the  calling  job  the  message
03600	procedure  SEND_DATA(MAXCNT,DAT).   It  must  be  killed  by  the job
03700	receiving it and need not be acknowledged.
03800	
03900	9.  SCAN A RECTANGLE FOR GUNNAR
04000	
04100	TTY: none
04200	MP: INSCAN(INTEGER TOP,BOTTOM,LEFT,RIGHT;REFERENCE INTEGER FILN);
04300	FILE: MISEDG  (INSCAN)
04400	
04500		A  rectangle  bounded  by the coordinates passed as arguments
04600	will be scanned and the edge points put  on  the  disk  as  described
04700	later  under  command INSIDE.  NOTE:  If boolean SLIM in library file
04800	GLOBAL, which is loaded with the edge follower,  is  TRUE,  the  scan
04900	will  follow  edges  outside the limits of the rectangle after having
05000	acquired them inside the rectangle.   If SLIM  is  FALSE,  as  it  is
05100	assembled,  the  scan  will not follow edges past the boundary of the
05200	rectangle. If FILN is a global  integer  it  will  contain  the  file
05300	number  on  exit.   The  GUNTRACE  command  can  be called after this
05400	command but no more edges will be found.
05500	
05600	10. TURN ON TYPEING
05700	
05800	TTY: EDGTYP
05900	MP: none
06000	FILE: MISEDG
06100	
06200		EDGTYP sets TYP_EDG in the upper  segment  for  when  the  HE
06300	monitor is not in use.
06400	
06500	11. TIMING
06600	
06700	TTY: TIMEIN and TIMOUT
06800	MP: none
06900	FILE: MISEDG
07000	
07100		TIMEIN store the current time.  TIMOUT types the runtime  and
07200	clock time since TIMEIN.
     

00100	III.  MAIN COMMANDS
00200	
00300		Below are descriptions of  the  main  commands  to  the  edge
00400	follower.   Except  for RELOOK, each takes one argument ARG.  For the
00500	message procedures, ARG is the item corresponding to the object to be
00600	processed.  If ARG=EVERY, all objects will be processed except,in the
00700	case of some commands, objects previously processed  by  the  command
00800	will  not  be processed again.  For TTY input, ARG is the item number
00900	or -1 for EVERY.  The  response  to  each  command  is,  for  message
01000	procedures,  the  return  of  the  message procedure RESPONSE (STRING
01100	NAME; INTEGER OBJECT, STATUS), where NAME is the command given (i.e.,
01200	"FIND",  "RELOOK",  etc.) and OBJECT is the item number of the object
01300	processed, if the command was successful, (note that it is passed  as
01400	an  integer; the item is CVI(OBJECT)).  See each description for what
01500	happens if no object is found.  STATUS tells the calling program what
01600	happened,   including  error  conditions  which  occurred.   For  TTY
01700	commands, the response to the TTY is NAME&CVS(OBJECT)&CVS(STATUS)  if
01800	CVI(OBJECT)≠NIL and NAME&"EVERY" otherwise.
01900	
02000		Associated with each of these commands is the command CANCEL,
02100	either from the TTY or as a message procedure name.  If  the  program
02200	is  processing a command operating on all objects, the CANCEL command
02300	causes it to terminate processing at the end of the current object.
02400	
02500	1. MAIN EDGE TRACING ROUTINE
02600	
02700	TTY: FIND 0 or FIND -1  (0≡NIL, -1≡EVERY)
02800	MP: FIND(ITEMVAR ARG)
02900	FILE: EDGE  (EDGE_KKP)
03000	
03100		Find an object and trace its outline.  Due to the  algorithm,
03200	more  that  one  object  may be traced by each call if they are close
03300	together. If ARG=NIL on entry, a new global item will be created  for
03400	each  object  traced  and the scan will stop when at least one object
03500	has been found or the end of the scan is reached.  If ARG is an  item
03600	which  appears in global set OLDBLOB, it will be used as the item for
03700	the first object found (mainly for the RELOOK command).   If  ARG  is
03800	anything else except EVERY it is equivalent to NIL. If ARG=EVERY, the
03900	entire image will be scanned from the starting point to find as  many
04000	objects  as  possible.   When first called the scan is initialized to
04100	start from a corner of the image.   XINC  and  YINC  determine  which
04200	corner  is  used.   The  scan  is  automatically reset to that corner
04300	whenever the end of the scan, at the diagonally opposite  corner,  is
04400	reached.  It  can  be  reset  to  the initial corner by executing the
04500	command SETVAL START 0.  Otherwise, at the  end  of  each  trace  the
04600	position  of  the scan is stored in XSTRT and YSTRT and the next scan
04700	starts  from  there. The accomodation routines set the target voltage
04800	to the auto target limit for the trace and only adjust clip levels.
     

00100		At  the end of the command, a "FIND" response is returned for
00200	each object found, giving the item number and status.    The  command
00300	always finishes with a "FIND" response with ARG=NIL and STATUS=-1. If
00400	this is the only response, no objects were found.   STATUS is decoded
00500	as follows:
00600	
00700	0	a closed curve was traced and nothing else
00800	1	at  least one edge being traced was lost due to the failure of
00900		the accomodation routines
01000	2	the  trace intersected either the edge it was tracing other
01100		than at the starting point, another edge of the same object,
01200		or an edge of a previously traced object. In the last case,
01300		the objects are merged and the item number of the previously
01400		seen object is returned again.
01500	4	at least one edge went  outside the limits of the area being
01600		scanned and SLIM was FALSE, or it went outside the TV field
01700		of view.
01800	64	no closed curve was found for this object
01900	
02000	The  numbers  are decimal and are ORed together. If STATUS<64 then an
02100	outline suitable for SIMPLE has been found.   IF  STATUS≥64  no  such
02200	outline is available, although further tracing in the area might find
02300	enough lines to complete the outline, or the curve  fitter  might  be
02400	able to complete it.  If STATUS>0 then inside edges were found also.
02500	
02600	2. FIT LINES TO EDGE POINTS
02700	
02800	TTY: FIT ARG
02900	MP: FIT(ITEMVAR ARG);
03000	FILE: MISEDG (CURVE)
03100	
03200		If  the  curve  fitting  program is running and linked to the
03300	same global segment as the edge follower, the edge  points  for  each
03400	object  will  be  passed  to the curve fitter by means of the message
03500	procedure CURVE_FIT and, after  acknowledgment,  the  lines  will  be
03600	displayed.   If the edge follower's debugging flag is set, the points
03700	will be superimposed over the lines.  The user cannot call the  curve
03800	fitter  directly  by a message procedure.  If the curve fitter is not
03900	available, command GETDATA will be executed for each object  to  dump
04000	the  edge  points  on  the disk as explained under that command.  The
04100	curve fitter can be run by  itself  off  of  the  files  put  out  by
04200	GETDATA.
04300	
04400		If  ARG  is  an object item, that object will be processed as
04500	described above and a response returned  with  the  item  number  and
04600	status.  If ARG=EVERY, all objects will be processed, except that the
04700	program will not curve  fit  an  object  twice  unless,  after  curve
04800	fitting,  more edges are traced which connect to the object.  In this
04900	last case, curve fitting can be done again to include the new segment
05000	which  might  produce  a better, or more complete, fit.  If it is fit
05100	again, the calling program must first delete the global  associations
05200	put  out  by  the  last fit and any other global structure created by
05300	later routines.
05400	
05500		The curve fitter put each item it fits in global  set  BLOBS.
05600	It also makes up to three associations for each object:
05700	
05800	XFORM⊗object≡new(T) where T is  the  camera  transform  from  Sobel's
05900	camera  model program.  If no transform is available, the association
06000	is not made.
06100	
06200	BOUNDARY⊗object≡new(A1)  where  A1  is  an  array with bounds 1:2,0:N
06300	containing the coordinates of the N corners of a  closed  outline  of
06400	the object, not necessarily the outermost closed outline (sorry about
06500	that J. Feldman). A1[1,0] contains N.  The corners are given in order
06600	around  the  object.   If  it has not closed outline, the association
06700	will not be made.
06800	
06900	INSIDE_EDGES⊗object≡new(A2)  where A2 is an array with bounds 1:4,0:M
07000	containing the coordinates of the end points of the M lines left over
07100	after filling A1. The coordinates are in each row of the array in the
07200	order X1, Y1, X2, Y2.  The lines are in no particular order.   If  A1
07300	contains  all edges, this association does not exist.  Again, A2[1,0]
07400	contains M.
07500	
07600	The status word in the response will contain one of the following:
07700	
07800	-1	If ARG=EVERY on entry, this means all objects have been  fit.
07850		The response  for  each  object has  already  been  returned.
07950		Otherwise,  either the object  requested did  not exist, has
08050		already been  curve fit,  or had less than three lines after
08150		fitting (in which case the object was deleted).   ARG=NIL in
08250		this response.
08300	
08400	0	fit ok
08500	1	fit ok but no closed curve was found.  SIMPLE will fail on this
08600		object.
08700	
08800	3. COMPACT THE DATA STRUCTURE
08900	
09000	TTY: COMPACT ARG
09100	MP: COMPACT(ITEMVAR ARG);
09200	FILE: MISEDG (COMP)
09300	
09400		This command deletes the edge points from the edge follower's
09500	data  structure for this object, which recovers a great deal of core,
09600	and turns off the edge follower's display, if any, for the object  if
09700	global flag YES_II is set (the II control program is running and will
09800	take over the display).  Future scans by the edge follower will  jump
09900	over  the  area  occupied  by  the  object without looking at it. The
10000	command needs a list of the  object's  corner  coordinates  which  it
10100	obtains  in  one  of  two  ways.   Since the object must be curve fit
10200	before  this  command  can  be  executed  on  it,   the   association
10300	BOUNDARY⊗ARG≡something  should  exist and can be used for compacting.
10400	If SIMPLE has processed the object, it has generated an  object  item
10500	(as  opposed  to  the  blob item from the edge follower which we have
10600	been using)  and  the  association  EDGES⊗OBJECT≡something.   If  the
10700	latter  association  exists,  it  will  be  used in preference to the
10800	BOUNDARD triple.  To retrieve it, the calling program must  have  put
10900	the  object  item  in  global  itemvar ITVAR_II. The object cannot be
11000	compacted more than once.
11100	
11200		ARG=EVERY is illegal for this command. If ARG is an object in
11300	the data structure it will be compacted.  If ARG is not an item known
11400	to the edge  follower,  a  new  object  is  generated  in  it's  data
11500	structure,  with  item  ARG,  and  it  is compacted. This last option
11600	allows a program using the edge follower to specify an area it is not
11700	to  look  at  while  scanning  by  generating  either  of  the global
11800	associations and calling compact with a new item.
11900	
12000		Also, if the TV is moved, call REJECT to get rid of  the  old
12100	data  structure  and  call  Sobel's  program  to  get  a  new  camera
12200	transform.  Run the corners, in table coordinates,  through  the  new
12300	transform   to   get  new  TV  coordinates,  put  them  back  in  the
12400	associations, and call compact with the old item number to generate a
12500	new  compacted  structure reflecting the object's current position in
12600	the field of view.  Only those lines, if any, in the field  of  view,
12700	are  stored  in  the  data structure. Lines partially in the field of
12800	view will be truncated. [WARNING: for objects  partially  inside  the
12900	field  of view the scan will do strange things thereafter.  There are
13000	some problems not yet taken care of].
13100	
13200		After an object has been compacted, the only  commands  which
13300	can refer to it are REJECT and RELOOK.  The status word may contain:
13400	
13500	-2	(ARG←NIL) Object ARG has neither association available.
13600	
13700	-1	(ARG←NIL) Object already compacted or ARG=EVERY on entry.
13800	
13900	0	ok - used EDGES association
14000	
14100	1	ok - used BOUNDARY association
14200	
14300	4. REJECT AN OBJECT
14400	
14500	TTY: REJECT ARG    (ARG=-1 for EVERY)
14600	MP: REJECT(ITEMVAR ARG);
14700	FILE: MISEDG   (REJSUB)
14800	
14900		The  object  specified,  or  all  objects  if  ARG=EVERY,  is
15000	deleted,  including  the  global  associations  XFORM,  BOUNDARY, and
15100	INSIDE_EDGES.  The item ARG is not deleted and is returned  with  the
15200	response. STATUS =-1, ARG =NIL if the object was not found, or at the
15300	end of REJECT(EVERY).  STATUS=0 otherwise.
     

00100	5. RELOOK AT AN OBJECT
00200	
00300	TTY: RELOOK ARG
00400	MP: RELOOK(ITEMVAR ARG; INTEGER X, Y);
00500	FILE:  MISEDG   (LOOK)
00600	
00700		The object specified is deleted  (by  REJECT)  and  the  edge
00800	follower  is  called to look for it again.  The first object found is
00900	assumed to be it.  The program sets up a rectangle fifteen resolution
01000	elements  larger than the object.  If X and Y are zero, the rectangle
01100	is centered at the center of the object; otherwise it is centered  at
01200	(X,Y).   The  scan starts with XSTRT←X and YSTRT←Y-{1/4 the height of
01300	the rectangle}. Only objects inside the rectangle will be found  but,
01400	once an object is located, the scan will follow its edges outside the
01500	rectangle if necessary.  FIND responses will  be  returned  for  each
01600	object  found,  if any.  The final output is the RELOOK response with
01700	ARG=NIL and STATUS=-1 if ARG was EVERY on entry or  no object  found;
01800	zero otherwise.
01900	
02000	6. DO A FINE SCAN
02100	
02200	TTY: FINE ARG (-1 for EVERY)
02300	MP: FINE(ITEMVAR ARG);
02400	FILE: EDGE (YFINE)
02500	
02600		The edge follower is called with full accomodation  to  do  a
02602	scan  with  a  very  small increment in the vicinity of the object to
02604	find small or less visible edges.   FIND responses will be  generated
02606	for everything found.  The FINE response is last and contains ARG=NIL
02608	and  STATUS=-1  if  ARG  was  EVERY  on  entry  or  no  objects; zero
02708	otherwise. You cannot fine scan an object twice.
03200	
03300	7. TRACE AN OBJECT FOR GUNNAR
03400	
03500	TTY: INSIDE ARG (-1 for EVERY, 0 for NIL)
03600	MP: INSIDE(ITEMVAR ARG);
03700	FILE: MISEDG   (INSUB)
03800	
03900		The arguments are the same as for  the  FIND  command.    The
04000	field of view is scanned by the edge follower as for the FIND command
04100	until an object has been traced.
04200		In addition to the regular data structure, two text files are
04300	created on the disk with the names n.EDG and (n+1).EDG,  where  n  is
04400	chosen larger than in any such file currently present.  In (n+1).EDG,
04500	each line contains the X and Y coordinates of a point on the edge and
04600	the  X  and Y components of the normal to the edge at that point. The
04700	file is updated every 100 points and all objects are put in the  file
04800	together.
04900		The first file, n.EDG, contains the following data:
05000	line 1:		the number of lines in (n+1).EDG as an integer
05100	line 2:		0
05200	line 3:		the trace spacing as an integer
05300	line 4:		-1 if lines 5-12 are valid, 0 otherwise
05400	line 5-12	if the CAMERA program put a transform into the global
05500			model, it is written out as a 8x3 array, 3 numbers to
05600			a line.
05700		line 5-7	the 3x3 camera transform (table→tv)
05800		line 8		the 1x3 lens center (table)
05900		line 9		the 1x2 center of the field of view (tv)
06000		line 10-12	the 3x3 inverse transform (tv→table)
06100	
06200		If only Gunnar is going to use the output you ought to delete
06300	the object and global associations to save space.
06400	
06500		FIND responses are generated as usual and the INSIDE response
06600	has ARG=NIL and STATUS is:
06700	0	file INSIDE could not be entered
06800	-1	no object found 
06900	-n	ok, n is the first file number (n>1)
07000	
07100	
07200	8. SCAN INSIDE FOR GUNNAR
07300	
07400	TTY:	GUNTRACE ARG,FILE  (only one object allowed)
07500	MP:	GUNTRACE(SET ARGS; INTEGER FILE);
07600	FILE:	MISEDG (FINSCN)
07700	
07800		ARGS are the items traced by INSIDE whose data  is  in  files
07900	n.EDG  and  (n+1).EDG  (n  is the file number from INSIDE which is in
08000	FILE).  The inside of all items in ARGS is scaned for more edges  and
08100	the  output is put in file (n+2).EDG.  The line count for the file is
08200	put on line 2 of  file  n.EDG.   If  FILE  contains  8,  the  control
08300	information  is  in  8.EDG, the outside edge points in 9.EDG, and the
08400	inside edges in 10.EDG.
     

00100		*** THE REST OF THIS IS MAINLY FOR ME ***
00200	
00300	THE INTERNAL EDGE DATA STRUCTURE
00400	
00500	
00600		TOPLST
00700		  ↓
00800	__________________
00900	|      TOP       |
01000	| OBJPNT | NULL  |
01100	|________________|
01200	
01300	
01400	OBJLST (last object processed-one for each object)
01500	     ↓
01600	_______________________      OBJPNT
01700	|     OBJECT          |        ↓
01800	|     OBJRNG          |↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔
01900	| CORPNT   | OUTLIN   |
02000	|----------------¬¬¬¬¬|		STATUS BITS
02100	|PNTNUM (# of points  |
02200	|DISFRM (frame #)     |     1	a closed trace exists (bits 1,2,
02300	|OBJNUM (item)        |			or 4 set for some segment
02400	|TOP (min y coord.)   |     8	all segments have been curve fitted
02500	|BOT (max y coord.)   |     16	compacted
02600	|LEFT (min x coord.)  |     32	inside scanned by FINE or GUNTRACE
02700	|RIGHT (max x coord.) |     64	status returned to calling program
02800	|CAMERA TRANS. (item) |     128	object entirely outside field of view
02900	|_____________________|
03000	
03100		**** THE STRUCTURE BELOW EXISTS UNTIL COMPACTED ****
03200	
03300	   SEGLST  (last processed - one for each line segment)
03400	     ↓
03500	_______________     OUTLIN
03600	|   SEGMNT    |       ↓ 	STATUS BITS
03700	|   SEGRNG    |↔↔↔↔↔↔↔↔↔
03800	|SEGPNT|NULL  |		   1,2,4  are the OR of all POINT status bit 1-4
03900	|_____________|		   32	  segment has been curve fitted
04000	
04100	
04200	    PNTLST  (last processed - one for each edge point)
04300	      ↓
04400	___________   SEGPNT	STATUS BITS
04500	|   POINT |     ↓   1	lost edge (bit 8 or 16 set also)
04600	|  PNTRNG |↔↔↔↔↔↔↔  2	intersected another edge    "
04700	|  WORLDR |↔↔↔↔↔↔↔  4	scan went outside field of view   "
04800	|---------|     ↑   8	no right extension of ring
04900	|    X    |  WORLDP 16	no left extension of ring
05000	|    Y    | (from   32	bit 1 was set and fine scan done in vicinity
05100	|_________| world model)
     

00100		**** STRUCTURE BELOW EXISTS ONLY AFTER COMPACTING ****
00200	
00300	_____________  WORLDP   (one for each grid square each line passes through)
00400	|  SEGMNT   |   ↓
00500	|  SEGRNG   |↔↔↔↔↔↔
00600	|SEGPNT|NULL|		128
00700	|___________|
00800	
00900	   SEGPNT (one for each line)
01000	    ↓
01100	__________________    CORPNT
01200	|      LINE      |     ↓
01300	|     CORRNG     |↔↔↔↔↔↔↔↔↔↔
01400	|----------------|
01500	| A   (coef. of  |
01600	| B     line     |
01700	| C     equation)|
01800	| X1 (first      |
01900	| Y1   endpoint) |
02000	| X2 (second     |
02100	| Y2   endpoint) |
02200	| D  (A↑2+B↑2)   |
02300	|________________|
02400	
02500	
02600		**** WORLD MODEL ****
02700	
02800	  PTSEEN TABLE
02900	      ↓
03000	______________
03100	|    LNK     |
03200	|DWN  | NULL |
03300	|____________|
03400	
03500	¬¬¬¬¬¬¬¬¬¬¬¬¬¬   DWN
03600	|    WORLD   |    ↓	STATUS BITS
03700	|   SQRING   |↔↔↔↔↔↔↔↔	128  compacted
03800	| WORLDP|NULL|
03900	|------------|
04000	|OBJECT item |
04100	|____________|
04200	
04300	WORLDP points to ring of point blocks, or a segment and line block 
04400		if compacted.